package ysq.xyg.host.model.po;

import cn.hutool.core.util.StrUtil;
import lombok.NoArgsConstructor;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import ysq.xyg.base.util.BaseConstant;
import ysq.xyg.base.util.BaseUtil;
import ysq.xyg.sys.model.po.SysUser;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 房产-楼盘房型实体类
 *
 * @author congcong tao
 * @date 2019-12-11 15:18:38
 */
@Data
@NoArgsConstructor
@Table(name = "xyg_host_item_layout")
public class HostItemLayout implements Serializable{

	/**
     * 主键
     */ 
	@Id
	private String id;

	/**
     * 楼盘主键
     */ 
	@Column(name = "item_id")
	private String itemId;

	/**
     * 名称
     */ 
	@Column(name = "name")
	private String name;

	/**
     * 介绍
     */ 
	@Column(name = "description")
	private String description;

	/**
	 * 首供
	 */
	@Column(name = "first_supply")
	private String firstSupply;

	/**
     * 1-n户型，使用code码uuid
     */ 
	@Column(name = "type")
	private String type;

	/**
     * 房型封面图片
     */ 
	@Column(name = "cover_image")
	private String coverImage;

	/**
     * 房型多图片
     */ 
	@Column(name = "images")
	private String images;

	/**
     * 内容
     */ 
	@Column(name = "content")
	private String content;

	/**
     * 参考总价
     */ 
	@Column(name = "all_price")
	private String allPrice;

	/**
     * 排序
     */ 
	@Column(name = "order_num")
	private Integer orderNum;

	/**
     * 创建者
     */ 
	@Column(name = "create_user")
	private String createUser;

	/**
     * 更新者
     */ 
	@Column(name = "update_user")
	private String updateUser;

	/**
     * 删除状态1、未删除2、已删除
     */ 
	@Column(name = "remove_tag")
	private String removeTag;

	/**
     * 创建时间
     */ 
	@Column(name = "create_time")
	private Date createTime;

	/**
     * 更新时间
     */ 
	@Column(name = "update_time")
	private Date updateTime;

	public String[] getImageList() {
		if (StringUtils.isEmpty(images)) {
			return new String[0];
		}
		return StrUtil.split(images, ",");
	}

	public HostItemLayout(SysUser sysUser) {
		this.id= BaseUtil.uId();
		this.removeTag= BaseConstant.BASE_REMOVE_TAG_NORMAL;
		this.createTime = new Date();
		this.createUser = sysUser.getId();
		this.updateTime = new Date();
		this.updateUser = sysUser.getId();
	}
}